package com.lvmama.rhino.enums;

import java.util.ArrayList;
import java.util.List;

/**
 * 新品类枚举
 * @author caoyong
 * @version 1.0.0
 * @since 2018-03-23 10:36
 **/
public enum NewCategoryEnum {
    DOMESTIC_TICKET("01","国内门票","01景乐_国内门票"),
    OVERSEAS_TICKET("02","境外门票","02景乐_境外门票"),
    HOTEL("04","酒店","04酒店自由行_单酒"),
    HOTEL_TICKET("05","景酒","05酒店自由行_景酒"),
    LONG_GROUP("06","国内长线跟团","06国内跟团_长线跟团"),
    AROUND_GROUP("07","国内周边跟团","07国内跟团_周边跟团"),
    FREE_WALKER("08","机酒自由行","08机酒自由行"),
    OVERSEAS_GROUP("09","出境游跟团游","09出境游_跟团游"),
    OVERSEAS_FREE_WALKER("10","出境游自由行","10出境游_自由行"),
    OVERSEAS_CRUISE_SHIP("11","出境游邮轮","11出境游_邮轮"),
    OVERSEAS_OTHER("12","出境其他","12出境其他"),
    TRAIN_TICKET("98","火车票","98火车票"),
    AIR_TICKET("99","飞机票","99飞机票"),
    LAST_MONTH_USER("101",null,"上月下单用户数"),
    DOWN_REPURCHASE_USER("102",null,"下游复购用户"),
    OTHER_REPURCHASE("103",null,"其他品类复购数"),
    UP_REPURCHASE_USER("104",null,"上游复购用户"),
    LAST_MONTH_USER_ALL("105",null,"上月下单用户总数"),
    UP_REPURCHASE_USER_ALL("106",null,"上游复购用户总数"),
    UP_REPURCHASE_RATE("201",null,"上游复购率"),
    DOWN_REPURCHASE_RATE("202",null,"下游复购率"),
    SELF_REPURCHASE_RATE("203",null,"自品类复购率"),
    ACROSS_REPURCHASE_RATE("204",null,"交叉复购率");
    private String code;
    private String showName;
    private String value;

    public String getCode() {
        return code;
    }

    public String getShowName() {
        return showName;
    }

    public String getValue() {
        return value;
    }

    NewCategoryEnum(String code, String showName, String value) {
        this.code = code;
        this.showName = showName;
        this.value = value;
    }

    /**
     * 获取枚举
     * @param code 编码
     * @return 品类枚举
     */
    public static NewCategoryEnum getEnum(String code){
        for (NewCategoryEnum en : NewCategoryEnum.values()){
            if(en.getCode().equals(code)){
                return null;
            }
        }
        return null;
    }

    /**
     * 获取枚举
     * @param value 枚举值
     * @return 品类枚举
     */
    public static NewCategoryEnum getEnumByValue(String value){
        for (NewCategoryEnum en : NewCategoryEnum.values()){
            if(en.getValue().equals(value)){
                return en;
            }
        }
        return null;
    }

    /**
     * 获取复购分布表头
     * @return 枚举数组
     */
    public static NewCategoryEnum[] getTableShowNameEnum(){
        List<NewCategoryEnum> showNameList = new ArrayList<>();
        for (NewCategoryEnum en : NewCategoryEnum.values()){
            if(null == en.getShowName() || OTHER_REPURCHASE.getCode().equals(en.getCode()) || UP_REPURCHASE_USER.getCode().equals(en.getCode())){
                continue;
            }
            showNameList.add(en);
        }
        NewCategoryEnum[] allCategories = new NewCategoryEnum[showNameList.size()];
        return showNameList.toArray(allCategories);
    }
}
